<template>
	<view class="page">
		<view class="bar_info" :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx'}">
			<view class="title_bar">
				<view class="title_bar_left" @tap.stop="isBack">
					<u-icon size="38" color="#000" name="arrow-left"></u-icon>
				</view>
				<view class="title_bar_center">
					<text>银行卡</text>
				</view>
				<view class="title_bar_right"></view>
			</view>
		</view>
		<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>

		<view class="loading_css" v-if="isShow">
			<u-loading size="36" color="#0E7EFD"></u-loading>
			<view class="loading_text">加载中</view>
		</view>

		<view class="list" v-else>
			<view class="list_item" v-for="(v, k) in list" :key="k" @tap.stop="goDetails(v.id)">
				<view class="item_title">{{v.title}}</view>
				<view class="item_content">
					<view class="item_content_left">
						<u-lazy-load :image="v.thumb" mode="aspectFill" border-radius="8"></u-lazy-load>
					</view>
					<view class="item_content_right">
						<view class="item_content_text">
							<view class="item_content_text_1"></view>
							<view class="item_content_text_2">{{v.desc}}</view>
							<!-- <view class="item_content_text_2">
								刷卡免年费，享吃喝玩乐优惠刷卡免年费，</view> -->
						</view>
						<view class="item_content_price">
							<text class="item_content_price_1"></text>
							<text class="item_content_price_2" v-if="v.price == 0">免费</text>
							<text class="item_content_price_2" v-else>{{v.price}}</text>
						</view>
					</view>
				</view>
			</view>
			<u-loadmore v-if="last_page > 1" class="loadmore" font-size="24" :status="status"
				:icon-type="iconType" :load-text="loadText" />
			<view class="noData" v-if="list.length == 0 && !isShow">
				<image src="/static/empty/no.png"></image>
				<view>没有银行卡~</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				image: '/static/index/3.png',
				isShow: true,
				card_cate_id: "",  // 分类id
				list: [],
				"page": 1,
				"is_pull": true,
				"last_page": 1,
				"status": 'loadmore',
				"iconType": 'flower',
				"loadText": {
					loadmore: '轻轻上拉',
					loading: '努力加载中',
					nomore: '我也是有底线的'
				},
				
			}
		},
		onLoad(option) {
			let { id } = option;
			if (id !== undefined) this.card_cate_id = id; 
			this.getList();
		},
		// 下拉刷新
		onPullDownRefresh() {
			this.page = 1;
			this.is_pull = true;
			this.isShow = true;
			this.getList();
		},
		// 上拉加载
		onReachBottom() {
			if (this.page >= this.last_page) return;
			this.status = 'loading';
			this.page++;
			setTimeout(() => {
		
				if (this.page >= this.last_page) this.status = 'nomore';
				else this.status = 'loading';
				this.is_pull = false;
				this.getList();
			}, 500)
		},
		methods: {
			// 根据分类获取银行卡
			getList() {
				this.$api.post(global.apiUrls.postCardList, {
					card_cate_id: this.card_cate_id,
					page: this.page
				}).then(res => {
					// console.log(res);
					uni.stopPullDownRefresh();
					this.isShow = false;
					if (res.data.code == 1) {
						this.last_page = res.data.data.last_page;
						if (this.is_pull) {
							this.list = res.data.data.data;
						} else {
							this.list = this.list.concat(res.data.data.data);
						}
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},

			goDetails(id) {
				uni.navigateTo({
					url: '/pages/index/details?id=' + id
				})
			},
			isBack() {
				uni.navigateBack();
			}
		}
	}
</script>

<style lang="scss" scoped>
	.page {
		.bar_info {
			width: 750rpx;
			height: 88rpx;
			overflow: hidden;
			// border-bottom: 1px solid #eee;
			// background: #fff;
			z-index: 10;
			position: fixed;
			top: 0rpx;

			.title_bar {
				padding: 0 32rpx;
				display: flex;
				justify-content: space-between;

				.title_bar_left {
					width: 50rpx;
					display: flex;
					align-items: center;
				}

				.title_bar_center {
					line-height: 88rpx;
					font-size: 36rpx;
					font-weight: 400;
				}

				.title_bar_right {
					width: 50rpx;
				}
			}
		}

		.list {
			padding: 30rpx;

			.list_item {
				background: #fff;
				border-radius: 20rpx;
				padding: 35rpx 26rpx 52rpx;
				margin-bottom: 24rpx;

				.item_title {
					font-size: 30rpx;
					font-weight: 900;
				}

				.item_content {
					margin-top: 24rpx;
					display: flex;

					.item_content_left {
						width: 242rpx;
						height: 152rpx;

						/deep/.u-lazy-item {
							width: 242rpx !important;
							height: 152rpx !important;
						}
					}

					.item_content_right {
						width: calc(100% - 242rpx);
						padding: 0 0 0 35rpx;

						.item_content_text {
							display: flex;
							// align-items: center;
							margin-bottom: 10rpx;
							max-height: 110rpx;

							.item_content_text_1 {
								display: inline-block;
								width: 10rpx;
								height: 10rpx;
								background: #ccc;
								border-radius: 50%;
								margin-right: 12rpx;
								transform: translateY(12rpx);
							}

							.item_content_text_2 {
								width: calc(100% - 22rpx);
								line-height: 36rpx;
								font-size: 24rpx;
								color: #666;
								word-break: break-all;
								text-overflow: ellipsis;
								overflow: hidden;
								display: -webkit-box;
								-webkit-box-orient: vertical;
								-webkit-line-clamp: 3;
								/* 这里是超出几行省略 */
							}
						}

						.item_content_price {
							display: flex;
							align-items: center;
							.item_content_price_1 {
								display: inline-block;
								width: 10rpx;
								height: 10rpx;
								background: #FF8A00;
								border-radius: 50%;
								margin-right: 12rpx;
							}

							.item_content_price_2 {
								font-size: 24rpx;
								color: #FF8A00;
							}
						}
					}
				}
			}
		}
	}
</style>